#include "gamehall.h"

GameHall::GameHall(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setFixedSize(1000, 800);
    this->setWindowTitle("贪吃蛇游戏");
    this->setWindowIcon(QIcon(":/res/ico.png"));

    QPushButton* startButton(new QPushButton(this));
    startButton->setText("开始游戏");
    startButton->move(this->width() / 2.2, this->height() / 1.5);
    startButton->setFont(QFont("华文行楷", 15));
    startButton->setStyleSheet("QPushButton{background: white; padding: 8px 15px; border: 1px solid white; border-radius: 15px}");
    startButton->setCursor(QCursor((Qt::CursorShape::PointingHandCursor)));

    connect(startButton, &QPushButton::clicked, this, [=](){
        QSound::play(":/res/clicked.wav");
        GameSelect* gameselect = new GameSelect;
        gameselect->setFixedSize(this->width(), this->height());
        this->close();
        gameselect->show();
    });
}

GameHall::~GameHall()
{
    delete ui;
}

void GameHall::paintEvent(QPaintEvent *event)
{
    (void)event;
    QPainter painter(this);
    QPixmap pixmap(":/res/game_hall.png");
    painter.drawPixmap(0, 0, this->width(), this->height(), pixmap);
}

